package com.forgenet.game.module.player.gm.controller;

import com.forgenet.game.module.player.Player;
import com.forgenet.game.module.player.gm.manager.GMManager;
import com.forgenet.message.gm.req.ReqUseGMPacket;
import com.forgenet.message.gm.resp.RespUseGMPacket;
import com.sparrow.common.util.StringUtil;
import com.sparrow.event.annotation.EventReceiver;
import com.sparrow.socket.tcp.anno.PacketHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 管理员命令
 */
@PacketHandler
@Component
public class GMController {

    private static Logger logger = LoggerFactory.getLogger(GMController.class);
    @Autowired
    GMManager gmManager;

    @EventReceiver
    public void reqUseGM(Player player, ReqUseGMPacket req) {
        if (StringUtil.isEmpty(req.getCommand())) {
            return;
        }
        boolean suc = gmManager.useCommand(player, req.getCommand());

        RespUseGMPacket resp = new RespUseGMPacket();
        resp.setSuc(suc);
        player.sendPacket(resp);
    }


}
